package com.ruoyi.web.controller.project.otherfile;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.project.otherfile.OtherFile;
import com.ruoyi.system.service.project.IOtherFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他档案Controller
 * 
 * @author ruoyi
 * @date 2025-10-08
 */
@RestController
@RequestMapping("/project/otherfile")
public class OtherFileController extends BaseController
{
    @Autowired
    private IOtherFileService otherFileService;

    /**
     * 查询其他档案列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OtherFile otherFile)
    {
        startPage();
        List<OtherFile> list = otherFileService.selectOtherFileList(otherFile);
        return getDataTable(list);
    }

    /**
     * 导出其他档案列表
     */
    @PreAuthorize("@ss.hasPermi('system:file:export')")
    @Log(title = "其他档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OtherFile otherFile)
    {
        List<OtherFile> list = otherFileService.selectOtherFileList(otherFile);
        ExcelUtil<OtherFile> util = new ExcelUtil<OtherFile>(OtherFile.class);
        util.exportExcel(response, list, "其他档案数据");
    }

    /**
     * 获取其他档案详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(otherFileService.selectOtherFileById(id));
    }

    /**
     * 新增其他档案
     */
    @Log(title = "其他档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OtherFile otherFile)
    {
        return toAjax(otherFileService.insertOtherFile(otherFile));
    }

    /**
     * 修改其他档案
     */
    @Log(title = "其他档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OtherFile otherFile)
    {
        return toAjax(otherFileService.updateOtherFile(otherFile));
    }

    /**
     * 删除其他档案
     */
    @Log(title = "其他档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(otherFileService.deleteOtherFileByIds(ids));
    }
}
